package com.edu.javaproect;

import com.edu.javaproect.address.BitCoinAddress;
import com.edu.javaproect.bean.HotVideo;
import com.edu.javaproect.service.GetBestBlockHashService;
import com.edu.javaproect.service.GetBlockHashService;
import com.edu.javaproect.service.HotVideoService;

import java.util.List;
import java.util.Scanner;

/**
 * @author:秇稔
 * @email:2580108178@qq.com
 * @Date:2021/12/6 20:05
 * @desc：该类是Java项目的主函数的类，是程序的
 **/
public class Main {
    public static void main(String[] args) {
        new Main().run();
    }
    public void run() {
        System.out.println("========JAVA期末考核大作业系统========");
        System.out.println("该系统已实现如下功能");
        while (true){
            menu();
        }
    }
    public void  menu(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("该系统已实现如下功能");
        System.out.println("1.旅游新势力榜");
        System.out.println("2.美食教程榜");
        System.out.println("3.地址生成");
        System.out.println("4.地址校验");
        System.out.println("5.获取最新区块的哈希值");
        System.out.println("6.获取总区块数");
        System.out.println("7.根据指定高度获取区块");
        System.out.println("0.退出");
        System.out.println("请输入您的选择");
        int num = scanner.nextInt();
        switch (num){
            case 1:
                System.out.println("旅游新势力榜：");
                HotVideoService hotVideoService = new HotVideoService();
                List<HotVideo> result = hotVideoService.getHotVideo();
                for (int i=0; i< result.size();i++){
                    System.out.println(result.get(i).toString());
                }
                break;
            case 2:
                System.out.println("美食总榜：");
                HotVideoService VideoService = new HotVideoService();
                List<HotVideo> result02 = VideoService.getHotVideo();
                for (int i=0; i< result02.size();i++){
                    System.out.println(result02.get(i).toString());
                }
                break;

            case 3:
                BitCoinAddress address = new BitCoinAddress();
                String str = address.newAddress();
                System.out.println("地址生成：" + str);
                break;
            case 4:
                BitCoinAddress address1 = new BitCoinAddress();
                System.out.println("请输入您要校验的btc地址：");
                String str1 = address1.newAddress();
                Scanner scanner1 = new Scanner(System.in);
                String str2 = scanner1.next();
                boolean result01 = address1.validataAddress(str2);
                System.out.println("地址校验："+result01);
                break;
            case 5:
                System.out.println("最新区块的哈希值");
                GetBestBlockHashService getBestBlockHashService = new GetBestBlockHashService();
                System.out.println(getBestBlockHashService.getBestBlockHash());
                break;
            case 6:
                System.out.println("区块总数为：");
                GetBestBlockHashService getBestBlockHashService1 = new GetBestBlockHashService();
                System.out.println(getBestBlockHashService1.getBlockCount());
                break;
            case 7:
                System.out.println("根据指定高度获取区块");
                int height = scanner.nextInt();
                GetBlockHashService getBlockHashService = new GetBlockHashService();
                System.out.println(getBlockHashService.getBlockHash(height));
                break;
            case 0:
                System.exit(0);
                break;
            default:
                System.out.println("暂不支持的功能，请重新输入");
                break;
        }
    }
}











































//        System.out.println("hello world");
//        HotVideoService hotVideoService = new HotVideoService();
//        for (HotVideo hotVideo : hotVideoService.getHotVideo()) {
//            System.out.println(hotVideo.getNickname());
//            System.out.println(hotVideo.getAvatar());
//            System.out.println(hotVideo.getEffect_value());
//            System.out.println(hotVideo.getFollower_count());
//            System.out.println(hotVideo.getVideo_list());
//        }

//        GetBestBlockHashService getBestBlockHashService = new GetBestBlockHashService();
//        String bestBlockHash = getBestBlockHashService.getBestBlockHash();
//        System.out.println(bestBlockHash);
